package com.memcached;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.rmi.server.Operation;
import java.util.concurrent.ExecutionException;

import net.spy.memcached.MemcachedClient;
import net.spy.memcached.internal.OperationFuture;

public class MemcachedTest {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        try {
        	// Connect to memcached server.
            MemcachedClient c = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));

            // Test string.
            c.set("hieutot", 10000, "HIEU HAY");
            String s = (String)c.get("hieutot");
            System.out.println(s);
            
            // Test object.
            Users users = new Users();
            users.setName("HIEUTOTBUNG");
            OperationFuture<Boolean> result = c.set("hieutot", 100000, users);
            boolean b = result.get();
            System.out.println("result: " + b);
            
            c.shutdown();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}